package com.example.demo.controller;

import com.example.demo.bean.BomDO;
import com.example.demo.service.BomService;
import com.example.demo.util.ClassUtil1;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class HelloController {

    //将Service注入Web层
    @Autowired
    BomService bomService;

    @RequestMapping("/index")
    public String sayHello()
    {
        return "index";
    }

    // http://localhost:8090/ss?muJianBianMa=0102010524&ziJianBianMa=0902040052
    @ResponseBody
    @RequestMapping(value = "/ss",method = RequestMethod.GET)
    public String login(String muJianBianMa, String ziJianBianMa){
        System.out.println();
        System.out.println("login(...)");
        System.out.println("muJianBianMa:"+muJianBianMa+", ziJianBianMa:"+ziJianBianMa);

        List<BomDO> list = bomService.getInfo(muJianBianMa, ziJianBianMa);
        if ((list != null)&&(list.size() > 0))
        {
            System.out.println("list:"+list.size());
            for (int i=0; i<list.size(); i++)
                System.out.println(ClassUtil1.objectToStr(list.get(i)));
            return "have";
        }
        else
            return "have not";
//        UserBean userBean = userService.loginIn(name,password);
//        if(userBean!=null){
//            return "success";
//        }else {
//            return "error";
//        }
    }

}
